package com.example.hello.Ui

import UIDemoState
import cn.UIDemo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.options.Configurable
import javax.swing.JComponent

/**
 * UI 配置界面配置类
 *
 * @author butterfly
 * @date 2023-12-06
 */
class UISettingsConfig: Configurable {

    private val form = UIDemo()

    private val component: JComponent

    private val state = ApplicationManager.getApplication().getService(UIDemoState::class.java)

    init {
        component = form.mainPanel
        reset()
    }

    override fun createComponent() = component

    override fun isModified(): Boolean {
        return state.address != form.address.text

    }
    override fun apply() {
        state.address = form.address.text
    }

    override fun reset() {
        form.address.text = state.address
    }

    override fun getDisplayName() = "UISettingsConfig"


}
